﻿@page
@model FangChanCrm.Views.GongGao.GongGaoShenPiModel
@{
}
<script src="~/admui-13945148017-1592211513218/public/themes/global/js/components/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.zh-CN.min.js"></script>
<link href="~/admui-13945148017-1592211513218/public/vendor/bootstrap-datepicker/bootstrap-datepicker.min.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/css/examples/tables/datatable.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.css" rel="stylesheet" />
<link href="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet" />
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables/jquery.dataTables.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap.min.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-bootstrap/dataTables.bootstrap4.js"></script>
<script src="~/admui-13945148017-1592211513218/public/vendor/datatables-responsive/dataTables.responsive.min.js"></script>
<div class="page-container" id="admui-pageContent">
    <div class="page animation-fade page-forms">
        <div class="page-header">
            <h1 class="page-title">公告列表</h1>
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a class="icon wb-home" href="javascript:;">公告管理</a>
                </li>
                <li class="breadcrumb-item active">公告列表</li>
            </ol>
        </div>
        <div class="page-content">
            <div class="panel">
                <div class="panel-body container-fluid">
                    <h4 class="example-title">公告信息</h4>
                    <div class="row">
                        <div class="form-group col-sm-3">
                            <label class="control-label" for="inputBasicPassword">标题</label>
                            <input type="text" class="form-control" id="BiaoTi" name="" placeholder="请输入标题名称" autocomplete="off" />
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="control-label" for="inputBasicPassword">发布时间</label>
                            <input type="text" class="form-control" data-plugin="datepicker" data-language="zh-CN" id="KaiShiShiJian" name="IptRuZhiShiJian">
                        </div>
                        <div class="form-group col-sm-3">
                            <label class="control-label" for="inputBasicPassword">状态</label>
                            <select class="form-control" id="slt_ZhuangTai" name="" data-fv-notempty="true" data-fv-field="requiredSelect">
                                <option value="0">请选择</option>
                                <option value="待审批">待审批</option>
                                <option value="已批准">已批准</option>
                                <option value="已驳回">已驳回</option>
                            </select>
                        </div>
                        <div class="form-group col-sm-3 row" style="text-align: center;padding-top:28px">
                            <div class="col-sm-6">
                                <button type="button" id="bt_ChaXun" class="btn btn-block btn-success" style="width: 100%; float: left;" onclick="ChaXun()"><i class="icon wb-search"></i>查询</button>
                            </div>
                            <div class="col-sm-6">
                                <button type="button" id="bt_ChongZhi" class="btn btn-outline btn-success" style="width: 100%;" onclick="ChongZhi();">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel-body">
                    <table class="table table-bordered table-hover dataTable table-striped w-full text-nowrap" id="dataTableExample" data-plugin="dataTable">
                        <thead>
                            <tr>
                                <th>标题</th>
                                <th>发布时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<button class="btn btn-primary" data-target="#exampleFormModal1" data-toggle="modal" type="button" id="btn_Xz1" style="display: none;">改数量</button>
<div class="modal fade example-modal-lg" id="exampleFormModal1" aria-hidden="true" aria-labelledby="exampleFormModalLabel" role="dialog" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog modal-lg" style="width: 100%; height: 63%">
        <div class="modal-content" style="width: 120%; height: 115%">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" id="guanbiaddkehu1" aria-label="关闭">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title" id="exampleFormModalLabel1">配置信息</h4>
            </div>
            <div class="modal-body" style="overflow: scroll;">
                <div class="row">
                    <div class="form-group col-sm-12">
                        <label class="control-label" for="inputInlinePassword">内容</label>
                        <textarea id="NeiRong" rows="5" cols="50" class="form-control" disabled="disabled"></textarea>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group col-sm-6" id="PiZhun">
                        <a class="btn btn-success btn-outline" onclick="ShenPi(1);" style="width: 20%; margin-left: 70%; margin-top: 20px;">批准</a>
                    </div>
                    <div class="form-group col-sm-6" id="BoHui">
                        <a class="btn btn-warning btn-outline" onclick="ShenPi(2);" style="width: 20%; margin-left: 10%; margin-top: 20px;">驳回</a>
                    </div>

                    <div class="form-group col-sm-12" id="FanHui">
                        <center>
                            <button class="btn btn-warning btn-outline" data-dismiss="modal" style="width: 20%; " type="button" aria-hidden="false" onclick="guanbi()">
                                返回
                            </button>
                        </center>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>
<div id="Id"></div>
<script type="text/javascript">
    $(document).ready(function () {
        $("#SpanGongGao").click();
        bang("", "", "");
    });
    function bang(BiaoTi, KaiShiShiJian, slt_ZhuangTai) {
        var lang = {
            "sProcessing": "大量处理中，请稍后...",
            "sLengthMenu": "每页 _MENU_ 项",
            "sZeroRecords": "没有匹配结果",
            "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
            "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
            "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
            "sInfoPostFix": "",
            "sSearch": "搜索:",
            "sUrl": "",
            "sEmptyTable": "表中数据为空",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页",
                "sJump": "跳转"
            },
            "oAria": {
                "sSortAscending": ": 以升序排列此列",
                "sSortDescending": ": 以降序排列此列"
            }
        };
        $("#dataTableExample").dataTable().fnDestroy();
        $('#dataTableExample').dataTable({
            "order": [[1, "asc"]],
            "language": lang,
            "processing": true,
            "serverSide": true,
            //"bStateSave": true,//状态保持模式
            "searching": false,//禁用搜索
            ajax: function (data, callback, settings) {
                //封装请求参数
                //console.log(data);
                var param = {};
                param.limit = data.length;//页面显示记录条数，在页面显示每页显示多少项的时候
                param.start = data.start;//开始的记录序号
                param.page = (data.start / data.length) + 1;//当前页码
                param.dir = data.order[0].dir;
                param.column = data.order[0].column;
                //console.log(param);
                param.BiaoTi = BiaoTi;
                param.KaiShiShiJian = KaiShiShiJian;
                param.slt_ZhuangTai = slt_ZhuangTai;
                //ajax请求数据
                $.ajax({
                    type: "POST",
                    url: "../GongGao/InitializationDataTable1",
                    cache: false,  //禁用缓存
                    data: param,  //传入组装的参数
                    dataType: "json",
                    success: function (result) {
                        console.log(result);
                        //setTimeout仅为测试延迟效果
                        setTimeout(function () {
                            //封装返回数据
                            var returnData = {};
                            returnData.draw = data.draw;//这里直接自行返回了draw计数器,应该由后台返回
                            returnData.recordsTotal = result.total;//返回数据全部记录
                            returnData.recordsFiltered = result.total;//后台不实现过滤功能，每次查询均视作全部结果
                            returnData.data = result.data;//返回的数据列表
                            //console.log(returnData);
                            //调用DataTables提供的callback方法，代表数据已封装完成并传回DataTables进行渲染
                            //此时的数据需确保正确无误，异常判断应在执行此回调前自行处理完毕"orderable" : false
                            callback(returnData);
                        }, 200);
                    }
                });
            },
            "columns": [
                { "data": "BeiZhu3" },
                { "data": "BeiZhu1" },
                { "data": "BeiZhu2" },
                { "data": null }
            ],
            columnDefs: [{
                //   指定第最后一列
                targets: -1,
                //加下面属性 不参与排序
                sortable: false,
                render: function (data, type, row, meta) {
                    //return '<button type="button" class="btn btn-outline btn-default" onclick="shebeiXG(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>修改</button>';
                    return '<button type="button" class="btn btn-outline btn-default" onclick="XiangXi(' + row.Id + ')"><i class="icon wb-pencil" aria-hidden="true"></i>查看</button>';
                }
            }]
        });
    }
    function ShenPi(panduan) {
        var Id = $("#Id").val();
        $.ajax({
            type: 'post',
            url: '../GongGao/GongGaoShenPi',
            dataType: 'text',
            async: true,
            data: { panduan: panduan, Id: Id },
            success: function (result) {
                alert("审批成功");
                $("#guanbiaddkehu1").click();
                bang("", "", "");
            }
        });
    }
    function XiangXi(Id) {
        $("#btn_Xz1").click();
        $("#Id").val(Id);
        $.ajax({
            type: 'post',
            url: '../GongGao/GongGaoHuiBang',
            dataType: 'json',
            async: true,
            data: { Id: Id },
            success: function (result) {
                $("#NeiRong").val(result.neiRong);
                if (result.zhuangTai == "待审批") {
                    $("#PiZhun").show();
                    $("#BoHui").show();
                    $("#FanHui").hide();
                } else {
                    $("#PiZhun").hide();
                    $("#BoHui").hide();
                    $("#FanHui").show();
                }
            }
        });
    }
    function ChaXun() {
        var BiaoTi = $("#BiaoTi").val();
        var KaiShiShiJian = $("#KaiShiShiJian").val();
        var slt_ZhuangTai = $("#slt_ZhuangTai").val();
        bang(BiaoTi, KaiShiShiJian, slt_ZhuangTai);
    }
    function ChongZhi() {
        $("#BiaoTi").val("");
        $("#KaiShiShiJian").val("");
        $("#slt_ZhuangTai").val(0);
        bang("", "", "");
    }

</script>
